package com.zfj.HashMap;

import com.zfj.HashSet.Person;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zfj
 * @date 2022/3/7 -17:08
 */
public class Demo1 {
	public static void main(String[] args) {
		HashMap<Student,String> student=new HashMap<>();
		Student s1=new Student("孙悟空",100);
		Student s2=new Student("猪八戒",101);
		Student s3=new Student("唐三藏",102);
		student.put(s1,"北京");
		student.put(s2,"上海");
		student.put(s3,"杭州");
		System.out.println(student.toString());
		//删除
		student.remove(s1);
		System.out.println(student.size());
		//遍历
		//使用keySet
		for (Student student1 : student.keySet()) {
			System.out.println(student1.toString()+"======="+student.get(student1));

		}
		//使用EntrySet
		for (Map.Entry<Student, String> entry : student.entrySet()) {
			System.out.println(entry.getKey()+"===="+entry.getValue());
		}
		//判断
		System.out.println(student.containsKey(s2));
	}
}
